package series;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Episode implements Comparable<Episode>{
	

	private int id;
	private int seriesId;
	private int seasonId;
	private int number;
	private String name;

	public Episode() {
		super();
	}
	
	public Episode(int id, int seriesId, int seasonId, int number, String name) {
		super();
		this.id = id;
		this.seriesId = seriesId;
		this.seasonId = seasonId;
		this.number = number;
		this.name = name;
	}

	@Override
	public int compareTo(Episode o) {
		return Integer.valueOf(number).compareTo(Integer.valueOf(o.number));
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getSeriesId() {
		return seriesId;
	}

	public void setSeriesId(int seriesId) {
		this.seriesId = seriesId;
	}

	public int getSeasonId() {
		return seasonId;
	}

	public void setSeasonId(int seasonId) {
		this.seasonId = seasonId;
	}

	public int getNumber() {
		return number;
	}

	public void setNumber(int number) {
		this.number = number;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + number;
		result = prime * result + seasonId;
		result = prime * result + seriesId;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Episode other = (Episode) obj;
		if (id != other.id)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (number != other.number)
			return false;
		if (seasonId != other.seasonId)
			return false;
		if (seriesId != other.seriesId)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Episode [id=" + id + ", seriesId=" + seriesId + ", seasonId="
				+ seasonId + ", number=" + number + ", name=" + name + "]";
	}
	

}
